function e(e, t, a) {
    return t in e ? Object.defineProperty(e, t, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = a, e;
}

var t = getApp(), a = require("../../339469457B99569C55F201426D89DBD0.js"), n = (require("../../38034BA77B99569C5E6523A090A9DBD0.js"), 
a.getImgCheckurl()), o = a.getFaceskinurl();

Page({
    data: {
        uploadimgs: "",
        showimages: "0",
        imageSrc: "https://heiyunke.com/789.jpg",
        width: "130px",
        height: "130px",
        percent: "75",
        count: 0,
        countTimer: null,
        setdatas: [ {
            image: "../../image/stain.png",
            name: "色斑",
            percent: "0"
        }, {
            image: "../../image/acne.png",
            name: "青春痘",
            percent: "0"
        }, {
            image: "../../image/dark_circle.png",
            name: "黑眼圈",
            percent: "0"
        } ],
        token: null
    },
    onLoad: function(e) {
        var a = t.data.openId;
        this.setData({
            openId: a
        });
        var n = this;
        n.countInterval(n.data.percent), n.drawProgressbg();
    },
    previewImage: function() {
        wx.previewImage({
            urls: [ this.data.imageSrc ]
        });
    },
    drawProgressbg: function() {
        var e = wx.createCanvasContext("canvasProgressbg", this);
        e.setLineWidth(8), e.setStrokeStyle("#e5e5e5"), e.setLineCap("round"), e.beginPath(), 
        e.arc(65, 65, 61, 0, 2 * Math.PI, !1), e.stroke(), e.draw();
    },
    countInterval: function(e) {
        var t = this;
        this.countTimer = setInterval(function() {
            t.data.count <= e ? (t.drawCircle(t.data.count / 50), t.data.count = t.data.count + .5, 
            t.setData({
                percent: parseInt(t.data.count)
            })) : (t.drawCircle(e / 50), t.setData({
                percent: parseInt(e)
            }), clearInterval(t.countTimer));
        }, 4);
    },
    drawCircle: function(e) {
        var t = wx.createCanvasContext("canvasProgress", this);
        t.setLineWidth(8), t.setStrokeStyle("#00BFFF"), t.beginPath(), t.arc(65, 65, 61, -Math.PI / 2, e * Math.PI - Math.PI / 2, !1), 
        t.stroke(), t.draw();
    },
    uploads: function() {
        var t = this;
        wx.chooseImage({
            count: 1,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(a) {
                t.setData({
                    img: a.tempFilePaths[0],
                    code: 1
                }), t.countInterval(t.data.percent), t.drawProgressbg(), setTimeout(function() {
                    wx.showLoading({
                        title: "肤质分析中...",
                        mask: !0
                    });
                }, 500), wx.uploadFile({
                    url: n,
                    filePath: a.tempFilePaths[0],
                    header: {
                        "content-type": "multipart/form-data"
                    },
                    name: "file",
                    formData: {
                        code: "XSYD"
                    },
                    success: function(n) {
                        var r = JSON.parse(n.data);
                        "0" == r.errcode ? wx.uploadFile({
                            url: o,
                            filePath: a.tempFilePaths[0],
                            header: {
                                "content-type": "multipart/form-data"
                            },
                            name: "file",
                            formData: {
                                openId: t.data.openId,
                                nickName: t.data.nickName
                            },
                            success: function(a) {
                                wx.hideLoading();
                                var n = a.data, o = JSON.parse(n);
                                if (console.info(o), "0" == o.code) {
                                    var r;
                                    t.setData((r = {
                                        code: 0,
                                        percent: o.health
                                    }, e(r, "setdatas[0].percent", o.stain), e(r, "setdatas[1].percent", o.acne), e(r, "setdatas[2].percent", o.darkCircle), 
                                    r)), t.countInterval(o.health), t.drawProgressbg();
                                } else "5" == o.code ? t.setData({
                                    info: o.msg
                                }) : "1" == o.code ? t.setData({
                                    info: o.msg
                                }) : t.setData({
                                    info: "Sorry 小程序远走高飞了"
                                });
                            },
                            fail: function(e) {
                                wx.hideLoading(), t.setData({
                                    info: "小程序离家出走了稍后再试"
                                });
                            }
                        }) : "87014" == r.errcode ? (wx.hideLoading(), wx.showModal({
                            content: "存在敏感内容，请更换图片",
                            showCancel: !1,
                            confirmText: "明白了"
                        }), t.setData({
                            img: null
                        })) : (wx.hideLoading(), wx.showModal({
                            content: "其他错误，稍后再试",
                            showCancel: !1,
                            confirmText: "明白了"
                        }));
                    }
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: "皮肤肤质分析小程序",
            path: "/pages/skin/skin",
            success: function(e) {
                "shareAppMessage:ok" == e.errMsg && wx.showToast({
                    title: "分享成功",
                    icon: "success",
                    duration: 500
                });
            },
            fail: function(e) {
                "shareAppMessage:fail cancel" == e.errMsg && wx.showToast({
                    title: "分享取消",
                    icon: "loading",
                    duration: 500
                });
            }
        };
    }
});